<template>
  <div>
    <div class="top">
      <van-icon @click="goback" class="zuo" name="arrow-left" />
      注册用户
    </div>
    <van-cell-group>
      <van-field v-model="value" label="手机号" placeholder="请输入手机号" />
    </van-cell-group>
    <van-button class="go" @click="golncc" :disabled="flag">下一步</van-button>
  </div>
</template>
  
  <script>
import { Toast } from "vant";
import { Reg } from "@/api/login";
export default {
  data() {
    return {
      value: "",

    };
  },
  computed: {
    flag() {
      if (/^1[3456789]\d{9}$/.test(this.value)) {
        //输入的内容符合正则规则
        return false; // 显示的红色可用
      } else {
        return true; //灰红色 禁用
      }
    },
  },
  methods: {
    goback() {
      this.$router.back();
    },
    golncc() {
      Reg({
        tel: this.value,
      }).then((res) => {
        let data = res.data;
        console.log(data);
        if (data.code == 200) {
          localStorage.setItem("tel",this.value)
          this.$router.push("/Yzm");
          console.log(data);
        } else {
          Toast("手机号已被注册或者格式不对");
          console.log(data);
        }
      });
    },
  },
};
</script>
  
  <style scoped>
.top {
  width: 100%;
  height: 3.125rem;
  font-size: 1.25rem;
  text-align: center;
  line-height: 3.125rem;
  /* border-bottom: 0.0625rem solid black; */
  position: relative;
  background-color: red;
}
.go {
  background-color: rgb(255, 166, 2);
  width: 18.75rem;
  height: 2.5rem;
  border-radius: 0.625rem;
  border: none;
  position: absolute;
  left: 2.5rem;
  top: 12.5rem;
}
.zuo {
  position: absolute;
  left: 0.625rem;
  font-size: 1.25rem;
  top: 0.9375rem;
}
</style>